Laboratory 3
CSSE 432 - Computer Networks

Due: Monday, April 9, 2012 by 11:55 PM

Purpose

Learn more client/server programming.

Simple FTP Client

During the next few labs, we will write a client to a simple FTP service. While traditional FTP supports dozens of operations (see man ftp for details), we will be implementing 3 main features: ECHO, GET, and PUT.

Like ECHO, both GET and PUT require an additional argument, which in this case is the name of the file to transfer. Unlike the traditional FTP protocol, this client uses UDP for communication, so our client will have to use a protocol capable of detecting and handling errors. The error-control method we will be using operates on sets of 5 DATA packets. After sending the GET request, the server will respond with up to 5 DATA packets. The client should respond to receiving the 5 DATA packets using an ACK packet with the same sequence number. After acknowledging, the server will send another set of DATA packets. After the entire file is sent, the server will send an ACK packet to mark the end of the file. The client should respond with a final ACK packet to finish the file transfer. Consider the following example file transfer:

Client               Server
------               ------
 GET    ----------->
        <----------- DATA  0
        <----------- DATA  1
        <----------- DATA  2
        <----------- DATA  3
        <----------- DATA  4
 ACK  4 ----------->
        <----------- DATA  5
        <----------- DATA  6
        <----------- DATA  7
        <----------- DATA  8
        <----------- DATA  9
 ACK  9 ----------->
        <----------- DATA 10
        <----------- DATA 11
        <----------- DATA 12
        <-----------  ACK 12
 ACK 12 ----------->

Failing to communicate with the server within 1.5 seconds of receiving the last packet will result in the server terminating its session with the client and start waiting for new requests. For this reason, it is important that your client sends the final ACK packet to complete the file transfer (the reason for having a final ACK packet will become more clear when the server starts dropping packets in subsequent labs). The timeout can be increased (so you can use things like gdb) by using the -t flag when starting the server.

The server supports some other useful flags. Use the -x flag to print packet graphs like the one above. The -v flag can be used to display contextual state about the server, such as when it starts and stops a file transfer. Run the server with the -u flag for full usage information.

Instructions

  1. Checkout the project Lab03 from your svn repository (svn update should do the trick if you checked out your entire repository in Lab01). Write your solutions to the problem below in that folder.

  2. Modify your previous lab assignment (or modify the sample solution to the last lab assignment) to also allow the user to send "get file" requests. The client must prompt the user to see which command it should perform (currently only echo and get) and then perform the requested action with the parameter provided by the user. Note: the solution to the previous lab is committed to your repository in Lab02Solution.

  3. Send a GET request to the server, populating the data field of the packet with the name of the file to download.

  4. Receive the file from the server, writing it to the current directory with the same filename. Remember that if the file is over LOADSIZE bytes, the file will be sent in multiple return packets. For this lab, assume that all packets arrive correctly.

  5. Use the server program found in the Lab03/Server directory. There is also a test file test.txt available in this directory. Feel free to create other test files.

  6. Compile and run the programs on the Linux platform.

  7. Use a consistent set of coding standards. The GNU C coding standards are available at http://www.gnu.org/prep/standards/standards.html#Writing-C Sections to look at are "Comments", "Formatting", "Syntatic Conventions", and "Names".

  8. Submit the source files (.c), the header files (.h) and the Makefile to your svn repository.